<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="include/base.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
	<title>凯盛项目管理系统</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="css/loong.css" />
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body class="body">
	
	<%@ include file="include/top.jsp" %>
	
	
	<div class="container">
	  <div class="row row-inner">
		 <%@ include file="include/left.jsp" %>
		<div class="span8">
			
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0">
				<li class="active">
					<a href="task.html"><i class="icon-user"></i>联系人</a>
				</li>
			</ul>
			<div class="wall">
				
					
						<address>
							<h3>${sessionScope.contact.name}</h3>
							<p>${sessionScope.contact.companyname}</p>
							<small>手机</small>${sessionScope.contact.tel}<br/>
							<small>固话</small> ${sessionScope.contact.moblie}<br/><br/>
							<small>邮箱</small> ${sessionScope.contact.email}<br/>
							<small>地址</small>${sessionScope.contact.address}<br/><br/>
							<small>主页</small> <a href="http://www.hpu.edu.cn" style="color:#52264A">${sessionScope.contact.website}</a><br/>
							<small>微博</small> <a href="http://user.qzone.qq.com/804795012/infocenter" style="color:#52264A">${sessionScope.contact.weibo}</a><br/>
						</address>
						<div class="line">记录</div>
						
							
							
							<textarea  class="span5" name="content" id="contentinner" rows="3">请记录一下您与客户的交流记录</textarea>
							<br/>
							<button class="save" >发布</button>
							<!-- <blockquote>
							<h5></h5>
							<h6></h6>
							</blockquote> -->
							
							
							<c:if test="${not empty requestScope.notelist }">
								<c:forEach items="${requestScope.notelist }" var="item" >
										<blockquote>
											
										  <h5 id="note_inner">${item.content }</h5>
										  <h6 id="note_createtime">发表于：${item.time }</h6>
										  <a href="deleteNote.jspx?id=${item.id }" title="删除"><i class="icon-trash"></i></a>
										</blockquote>
										
									</c:forEach >
							</c:if>
						<a href="contactShow.jspx" style="color:#52264A">←返回联系人列表</a>
			</div>
		</div>
	  </div>
	   <%@ include file="include/foot.jsp" %>
	</div>
	<script type="text/javascript" src="js/json.js"></script>
	<script type="text/javascript" src="js/jquery.js"></script>
	
	<script type="text/javascript">
		$(document).ready(function(){
				
				var xmlHttp;
    	
	    	//创建Ajax引擎
	    	function createXmlHttp() {
	    		if(window.ActiveXObject) {
		    		//IE
	    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		    	} else {
		    		//Chrome firefox 
		    		xmlHttp = new XMLHttpRequest();
		    	}
	    	}
		
    	function callback() {
    		var serverCode = xmlHttp.readyState;
    		if(serverCode == 4) {
    			var httpCode = xmlHttp.status;
    			
    			if(httpCode == 200) {
    				 var note = eval('('+xmlHttp.responseText+')');
    				 	$(".save").after("<blockquote><h5></h5><h6></h6><a></a></blockquote>");
    				 	$("h5").first().html(note.content);
    				 	$("h6").first().html("发表于："+note.time);
    				 	$("blockquote a").first().attr("title","删除");
			   			$("blockquote a").first().attr("href","deleteNote.jspx?id="+note.id);
			   			$("blockquote a").first().attr("class","icon-trash");
    			} else {
    				alert("服务器忙，请稍后...");
    			}
    		}
    	}
    		
	    	 $(".save").click(function(){
		    	 var content = $("#contentinner").val();
		    	 //alert(content);
		    	 //1.创建Ajax引擎
	    		createXmlHttp();
	    		//2.告诉引擎请求的服务器地址(ajax.jspx)，请求方式(get)，是否异步请求(true)
	    		xmlHttp.open("post","save_note.jspx",true);
	    		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	    		//3.设置回调函数
	    		xmlHttp.onreadystatechange = callback;
	    		
	    		//4.请求服务器
	    		xmlHttp.send("content="+content);
			});
			 
			$("#contentinner").focus(function(){
			
				$(this).val("");
			});
		});
	
	</script>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
</body>
</html>